<?php

require_once('Tools/Tools.php');

$type = Tools::getValue('type');
$year = Tools::getValue('year');
$country = Tools::getValue('country');
$city = Tools::getValue('city');
$meeting = Tools::getValue('meeting');

$countries = '<payss totalRow="3">
<pays>France</pays>
<pays>Allemagne</pays>
<pays>Italie</pays>
</payss>';
$cities = '<villes totalRow="11">
<ville>Aix en Provence</ville>
<ville>Aix-les-Bains</ville>
<ville>Ajaccio</ville>
<ville>Albi</ville>
<ville>Amiens</ville>
<ville>Angers</ville>
<ville>Anglet</ville>
<ville>Annecy</ville>
<ville>Arcachon</ville>
<ville>Arles</ville>
<ville>Aussois</ville>
</villes>';
$meetings = '<meetings totalRow="2">
<meeting>
	<name>ACM 1</name>
	<address>Ajaccio, France</address>
	<themes>
		<theme>
			<name>T1</name>
			<percent>50</percent>
		</theme>
		<theme>
			<name>T2</name>
			<percent>50</percent>
		</theme>
	</themes>
</meeting>
<meeting>
	<name>ACM 2</name>
	<address>Nice, France</address>
	<themes>
		<theme>
			<name>T1</name>
			<percent>80</percent>
		</theme>
		<theme>
			<name>T2</name>
			<percent>20</percent>
		</theme>
	</themes>
</meeting>
</meetings>';


switch ($type) {
	case 'cities' : suggest_cities($cities);break;
	case 'countries' : suggest_countries($countries);break;
	case 'meetings' : suggest_meetings($meetings);break;
}

function suggest_cities($xml) {
	$xml = new SimpleXMLElement($xml);
	echo json_encode($xml);
}
function suggest_countries($xml) {
	$xml = new SimpleXMLElement($xml);
	echo json_encode($xml);
}
function suggest_meetings($xml) {
	$xml = new SimpleXMLElement($xml);
	echo json_encode($xml);
}

?>